<!DOCTYPE html>
<html>
	<head>
		<meta charset="UTF-8">
		<title></title>
		<meta name="viewport" content="width=device-width,initial-scale=1,minimum-scale=1,maximum-scale=1,user-scalable=no" />
		<link rel="stylesheet" href="../css/mui.css" />
		<link rel="stylesheet" href="../css/style.css" />
		<script type="text/javascript" src="../js/jquery-1.8.0.min.js" ></script>
		<script type="text/javascript" src="../js/mui.min.js" ></script>
		<script type="text/javascript" src="../js/head_public.js" ></script>
		<script type="text/javascript" src="../js/common.js" ></script>
		<script type="text/javascript" src="../js/session.js" ></script>
	</head>
	<body>
		<div class="login-container" id="login-container">
			<img src="../images/login-biao.png" class="login-biao" />
			<form class="login-form" id="wang-from">
				<p><input type="text"  name="member_mobile" placeholder="请输入手机号" id="phone"/><img src="../images/login-icon1.png"></p>
				<p class="yanzheng"><input type="text" name="sms_captcha" placeholder="请输入验证码"/><button type="button" id="hqyzm">验证码</button><img src="../images/login-icon2.png"></p>
				<p><input type="password" class="newpass" name="member_password" placeholder="设置新密码"/><img src="../images/login-icon3.png"></p>
				<p><input type="password" class="confirmpass" name="report_password" placeholder="确认密码"/><img src="../images/login-icon4.png"></p>
				<input type="hidden" id="true_yanzheng" name="true_captcha" />
				<input type="hidden" id="true_mobile" name="true_mobile" />
				<div class="go-login-div"><a data-href="login.html">去登录</a><a data-href="regiest.html">注册</a></div>
				<div class="sub-btn"><button type="button" class="submit">确定</button></div>
				<!--<div class="fengexian"><span><hr></span><span>其他登录方式</span><span><hr></span></div>
				<div>
					<ul class="sanfang-img">
						<li>
							<img src="../images/login-wx.png" />
						</li>
						<li>
							<img src="../images/login-zfb.png" />
						</li>
						<li>
							<img src="../images/login-qq.png" />
						</li>
					</ul>
				</div>-->
			</form>
		</div>
		
		<script>
        //倒计时
		    var t=59;
			function refer()
			{
				if(t==0)
				{
				   $("#hqyzm").prop("disabled",false);//取消禁用
				   $("#hqyzm").css({"background-color":"#ff7e00","border-color":"#ff7e00"});
				   $("#hqyzm").html("验证码");
				}else{
				   $("#hqyzm").html("验证码"+t+"s");
				   t--; // 计数器递减
				}
			}
		$(function() {	
			mui("body").on("tap","a",function(){
				mui.openWindow({
					url:$(this).attr("data-href")
				})
			})
				// 验证码获取倒计时
			mui(".login-container").on("tap","#hqyzm",function(){
			  // 检查手机号格式
			  disableBtn(this);
			  var username =/^1[0-9]{10,10}$/;
			  var phone=$("#phone").val();
			  if(phone==null||phone==''){
			    alert("账号不能为空");
			    return false;
			  }else if(!username.test(phone)){
			    alert("手机号格式不正确");
			    return false;
			  }
			  
			  $(this).css("background-color","#999");
			  var param = {};  //register
			  // Checkphone			
			  param.sms_mobile = phone;
			  param.type = "3";
	       
			  // 判断返回值
			 
			  $.post(net+"/public/index.php?s=api/login/get_captcha",param,function(res){
			  	  if (res.code=="200") {
			  	  	$("#true_yanzheng").val(res.result.sms_captcha)
			  	  	$("#true_mobile").val(res.result.sms_mobile)
					$("#hqyzm").attr("disabled","disabled");
					$("#hqyzm").css({"background-color":"#999","border-color":"#999"});
				  	var inter=setInterval("refer()",1000); //启动1秒定时
				  }else {
				    alert(res.message);
				  }
			  }) 
			})
			mui("body").on("tap",".submit",function(){		
				var $passwd = /^\w{6,12}$/;
				var params = $("#wang-from").serializeObject();
				var phone=$("#phone").val();
				//验证表单
				console.log(params)
				if(params.sms_captcha==""||params.sms_captcha==null){
	            	alert("请填写手机验证码")
	            	return false;
				}else if(params.member_password==""||params.member_password==null){
					alert("请填写新密码")
					return false;
				}else if(!$passwd.test(params.member_password)){
					alert("新密码为6-12字母或者数字！")
					return false;
				}else if(params.report_password==""||params.report_password==null){
					alert("请填写确认密码");
					return false;
				}else if(!$passwd.test(params.report_password)){
					alert("确认密码为6-12字母或者数字！")
					return false;
				}else if(params.report_password!=params.member_password){
					alert("新密码与确认密码不一致")
					return false;
				}
				console.log(params)
				params.sms_mobile=phone;
				$.post(net+"/public/index.php?s=api/login/forgetpass",params,function(res){
					if(res.code=="200"){
						alert(res.message)
						location.href="login.html"
					}else{
						alert(res.message)
					}
					
					
				})
			})
			
			mui(".forget-container").on("tap",".wang-close",function(){
				$(".forget-container").hide();
			}) 
	    });
	    $.fn.serializeObject = function() {  
	        var o = {};  
	        var a = this.serializeArray();  
	        $.each(a, function() {  
	            if (o[this.name]) {  
	                if (!o[this.name].push) {  
	                    o[this.name] = [ o[this.name] ];  
	                }  
	                o[this.name].push(this.value || '');  
	            } else {  
	                o[this.name] = this.value || '';  
	            }  
	        });  
	        return o;  
	    }
		</script>
	</body>
</html>
